package com.ruoyi.service.impl;

import com.ruoyi.vo.VehicleVo;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.mapper.VehicleMapper;
import com.ruoyi.pojo.Vehicle;
import com.ruoyi.service.VehicleService;

@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
    @Autowired
    private VehicleMapper vehicleMapper;


    @Override
    public List<VehicleVo> selectByVehicleAnoModel(String vin) {
        return vehicleMapper.selectByVehicleAnoModel(vin);
    }

    @Override
    public List<Vehicle> selectAll() {
        return vehicleMapper.selectAll();
    }

    @Override
    public boolean insertVehicle(Vehicle vehicle) {
        return vehicleMapper.insertVehicle(vehicle);
    }

    @Override
    public boolean deleteById(Long id) {
        return vehicleMapper.deleteById1(id);
    }

    @Override
    public boolean updateVehicle(Vehicle vehicle) {
        boolean code = vehicleMapper.deleteById1(Long.valueOf(vehicle.getId()));
        if (code){
            return vehicleMapper.insertVehicle(vehicle);
        }else {
            return false;
        }
    }
}
